﻿// -----------------------------------------------------------------------------
// Application.Data.Commander
Application.Data.Commander = {
	name: 'Chrius Maximus'
};

// ---

Application.Data.CommanderStages = [
	{ id: 1,	name: 'Rekrut' },
	{ id: 2,	name: 'Signatus' },
	{ id: 3,	name: 'Miles' }
];
Application.Collections.CommanderStages = new Backbone.Collection(Application.Data.CommanderStages);

// -----------------------------------------------------------------------------
// Application.Models.Commander
Application.Models.Commander = Application.Model.extend({
	defaults: {
		name: null,
		stage: 1
	},

	getters: {
		stage: function() {
			var id 		= Backbone.Model.prototype.get.call(this, 'stage');
			var stage	= Application.Collections.CommanderStages.get(id);
			
			return stage;
		}
	}
});

// -----------------------------------------------------------------------------
// Application.Views.Map | Application.Views.Tile
Application.Views.Commander = Backbone.View.extend({
	el:	$('#commander'),
	template:	_.template($('#view-commander').html()),

	initialize: function() {
		this.model = new Application.Models.Commander(Application.Data.Commander);		
		this
			.render();
		
		return this;
	},

	render: function() {
		$(this.el).append(this.template(this.model.toJSON()));	
		return this;
	}
});